<!DOCTYPE html>
//<?php
//session_start();
//if(isset($_SESSION["uid"])){
//    //要求管理员才能访问
//    if($_SESSION["Usertype"]==1){
//        echo "<script>location='houtai/houtai.php';</script>";  
//    }else{
//      echo "<script>location='shouye.php';</script>";  
//    }
//}else{
//  echo "<script>location='denglu.php';</script>";
//}
//?>
<?php
 require 'common/mysqlCommon.php';  //将其他的php文件的代码引入当前页面
$frist=!count($_POST);
?>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <?php
        if($frist){
            if(isset($_GET["id"])){
                $uid=(int)$_GET["id"];
                if($uid){
                        $sqlstring="select * from gmz where uid=${uid}";
                        $result= getDataSetBySQL($sqlstring);
                        if(count($result)>0){
                            $row=$result[0];
                            ?>
                             <h1>用户编辑</h1>
                        <form action="caizhi.php" method="post" enctype="multipart/form-data">
                            <input type="hidden" name="uid" 
                                   value="<?php echo $row["uid"];?>" />
                        角色名：<input type="text" name="username" 
                                   value="<?php echo $row["username"];?>"/><br/>
                            头像：<img src="<?php echo $row["tp"]; ?>" style="width:100px;height:100px" />
                             <br/>
                            更改头像：<input type="file" name="myimg"/>
                            <br/>
                            <input type="submit" value="确定"/>
                            <input type="reset" value="取消" />
                            介&nbsp;&nbsp;绍：<input type="text" name="js"
                                   value="<?php echo $row["js"];?>"/><br/>
                        </form>
                            <?php
                        }else{
                            echo "参数错误3";
                        }
                   
                }else{
                    echo "参数错误2";
                }
            }else{
                echo "参数错误1";
            }
           
        }else{
            //页面处理数据
             $username=$_POST["username"];
             $js=$_POST["js"];
             $tp=$_POST["tp"];
             $sqlstr="update gmz set username='${name}',". "js='${js}',tp='${tp}' where uid=".$user_id;
             $result= getResultBySQL($sqlstr);
           if($result){
                echo "<script>alert('编辑成功！');"
                    . "location='gongmingzhe.php';</script>";
            }else{
                echo "<script>alert('添加失败,请重试!!');"
                    . "location='gongmingzhe.php';</script>";
            }
        }
        ?>
        
        <?php
        // put your code here
        ?>
    </body>
</html>